import request from '@/utils/request'
import qs from 'qs'

// 获取所有类别
export function getCategoryList (pageNumber, pageSize) {
  return request({
    url: '/cms/category/list',
    method: 'get',
    params: {
      pageNumber,
      pageSize
    }
  })
}


// 添加类别
export function addCategory (data) {
  return request({
    url: '/cms/category/save',
    method: 'post',
    data: qs.stringify(
      data
    )
  })
}

// 删除类别
export function deleteCategorys (ids) {
  return request({
    url: '/cms/category/delete',
    method: 'post',
    data: qs.stringify({
      ids
    }, {indices: false})
  })
}

// 编辑类别
export function updateCategory (category) {
  return request({
    url: '/cms/category/update',
    method: 'post',
    data: qs.stringify({
      id: category.id,
      name: category.name,
    }, {indices: false})
  })
}

// 获取所有类别
export function selectCategory () {
  return request({
    url: '/cms/category/select_item',
    method: 'get',
  })
}
